package com.qtt.app.service.impl;

import com.qtt.app.entity.Test.MsgBoard;
import com.qtt.app.mapper.MsgBoardMapper;
import com.qtt.app.service.MsgBoardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MsgBoardServiceImpl implements MsgBoardService {

    @Autowired
    MsgBoardMapper msgBoardMapper;

    @Override
    public List<MsgBoard> listAll() {
        List<MsgBoard> entities = msgBoardMapper.list();
        return entities;
    }

    @Override
    public Boolean addMsg(MsgBoard entity) {
        entity.setGmtCreate (new Date());//创建的时间就不用用户输入了，后端自动获取系统时间
        Boolean b = msgBoardMapper.save(entity);

        return b;
    }

    @Override
    public Boolean delete(long id) {
        Boolean b = msgBoardMapper.delete(id);
        return b;
    }

    @Override
    public Boolean update(long id, String msg) {
        Boolean b = msgBoardMapper.update(id,msg);
        return b;
    }
}
